# Copyright (C) Kumo inc. and its affiliates.
# Author: Jeff.li lijippy@163.com
# All rights reserved.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <https:#www.gnu.org/licenses/>.
#
#
# Copyright (c) 2024 by Rivos Inc.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0

function(breeze_add_perftests dir type)
  # only add test for platforms we support
  set(BUILD_OPENCL OFF)
  set(BUILD_METAL OFF)
  set(BUILD_SYCL OFF)
  set(BUILD_OPENMP OFF)
  set(BUILD_HIP OFF)

  if(BUILD_CUDA)
    set(_cuda_flags)
    set(_cuda_libs)
    list(APPEND _cuda_flags -DPERFTEST_EXT_TYPES=${PERFTEST_EXT_TYPES})
    list(APPEND _cuda_flags -I${CMAKE_SOURCE_DIR}/perftest)
    if(BUILD_TRACING)
      list(APPEND _cuda_flags -I${CMAKE_SOURCE_DIR}/../../external/perfetto/sdk)
      list(APPEND _cuda_flags -DTRACING=1)
    endif()
    breeze_add_tests(
      ${dir}
      ${type}
      "_perftest"
      ".cu"
      ${ARGN})
  endif()
endfunction()

breeze_add_perftests(
  "functions"
  "function"
  "reduce"
  "scan"
  "sort")
breeze_add_perftests(
  "algorithms"
  "algorithm"
  "reduce"
  "scan"
  "sort")
breeze_add_perftests("queries" "query" "order_by")
